/**
 * @FileName    TestHashSet.java
 * @Description 
 * @author      looton@163.com
 * @Time        2013-7-17:下午5:06:01
 */
package org.looton.advanced.ch22;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class TestHashSet {
	public static void main(String[] args) {
		// Create a hash set
		Set<String> set = new HashSet<String>();

		// Add strings to the set
		set.add("London");
		set.add("Paris");
		set.add("New York");
		set.add("San Francisco");
		set.add("Beijing");
		set.add("New York");

		System.out.println(set);

		// Obtain an iterator for the hash set
		Iterator<String> iterator = set.iterator();

		// Display the elements in the hash set
		while (iterator.hasNext()) {
			System.out.print(iterator.next().toUpperCase() + " ");

		}
		System.out.println();

		for (Object element : set) {
			System.out.print(element + " ");
		}
	}
}
